<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户更新</title>
<s:include value="/app_common/common.jsp"></s:include>
<!-- 表单验证start -->
<script src="<s:property value='webctx'/>/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="<s:property value='webctx'/>/libs/js/form/validation.js" type="text/javascript"></script>
<!-- 表单验证end -->
<!-- 树组件start -->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/tree/ztree/ztree.js"></script>
<link type="text/css" rel="stylesheet" href="<s:property value='webctx'/>/libs/js/tree/ztree/ztree.css"></link>
<!-- 树组件end -->
<!-- 树形下拉框start -->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/form/selectTree.js"></script>
<!-- 树形下拉框end -->
<!-- 日期选择框start -->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/form/datePicker/WdatePicker.js"></script>
<!-- 日期选择框end -->
</head>
<body>
	<div class="box1" panelWidth="500">
		<form name="form2" id="form2" method="post" target="frmright">
			<s:hidden name="user.u_id"></s:hidden>
			<table class="tableStyle" formMode="line">
				<tr>
					<th colspan="4">用户信息更新</th>
				</tr>
				<tr>
					<td>用户编码：</td>
					<td>
						<%--<s:if test="#session.u_name eq 'admin'"> --%>
							<input type="text" name="user.u_code" class="validate[required,length[4,20]]" value="<s:property value="user.u_code" />"><span class="star">*</span>
						<%--</s:if>
						<s:else>
							<s:if test="user.u_id==0">
								<input type="text" name="user.u_code" class="validate[required,length[4,20]]" value="<s:property value="user.u_code" />"><span class="star">*</span>
							</s:if>
							 普通员工无法更改CODE 
							<s:else>
								<input type="text" readonly="readonly" name="user.u_code" class="validate[required,length[4,20]]" value="<s:property value="user.u_code" />"><span class="star">*</span>
							</s:else>
						</s:else>--%>
					</td>
					<td>用户级别：</td>
					<td colspan="3">
						<select class="validate[required]" prompt="请选择" name="user.u_power" selectedValue="<s:property value='user.u_power'/>" data='{"list":[{"value":"1","key":"营业部"},{"value":"2","key":"分部"},{"value":"3","key":"普通"}]}'></select><span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td>姓名：</td>
					<td><input type="text" name="user.u_name" class="validate[required]" value="<s:property value="user.u_name" />"><span class="star">*</span></td>
					<td>性别：</td>
					<td>
						<select id="u_sex" name="user.u_sex" selectedValue="<s:property value='user.u_sex'/>" prompt="请选择" data='{"list":[{"value":"0","key":"男"},{"value":"1","key":"女"}]}' class="validate[required]"></select>
						<span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td>账户名：</td>
					<td><input type="text" class="validate[required,length[4,15]]" name="user.u_login_id" value="<s:property value="user.u_login_id" />"/><span class="star">*</span></td>
					<td>联系方式：</td>
					<td><input type="text" name="user.u_phone" class="validate[required]" value="<s:property value="user.u_phone" />" ><span class="star">*</span></td>
				</tr>
				<tr>
					<td>密码：</td><td><input type="password" value="<s:property value="user.u_login_pwd" />" name="user.u_login_pwd" id="pwd" class="validate[required,length[6,15],custom[noSpecialCaracters]]"><span class="star">*</span></td>
					<td>密码确认：</td><td><input type="password" value="<s:property value="user.u_login_pwd" />" id="pwdr" class="validate[required,confirm[pwd]]"><span class="star">*</span></td>
				</tr>
				<tr>
					<td>入职时间：</td>
					<td><input type="text" name="user.u_entry_date" value="<s:property value='user.u_entry_date'/>" class="date validate[required]" style="cursor: pointer;"><span class="star">*</span></td>
					<td>离职时间：</td>
					<td><input type="text" name="user.u_entry_date_end" value="<s:property value='user.u_entry_date_end'/>" class="date" style="cursor: pointer;"></td>
				</tr>
				<tr>
					<td>出生日期：</td>
					<td><input type="text" name="user.u_cs_date" value="<s:property value='user.u_cs_date'/>" class="date validate[required]" style="cursor: pointer;"><span class="star">*</span></td>
					<td>身份证号码：</td>
					<td><input type="text" name="user.u_card" value="<s:property value="user.u_card" />" maxlength="18"></td>
					
				</tr>
				<tr>
					<td>用户状态：</td>
					<td>
						<select class="validate[required]" prompt="请选择" name="user.u_status" selectedValue="<s:property value='user.u_status'/>" data='{"list":[{"key":"在职","value":"1"},{"key":"离职","value":"2"}]}'></select><span class="star">*</span>
					</td>
					<td>学历：</td>
					<td>
						<select class="validate[required]" prompt="请选择" name="user.u_xl" selectedValue="<s:property value='user.u_xl'/>" data='{"list":[{"key":"博士","value":"1"},{"key":"研究生","value":"2"},{"key":"本科","value":"3"},{"key":"大专","value":"4"},{"key":"高中及以下","value":"5"}]}'></select><span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td>所属角色：</td>
					<td>
						<select class="validate[required]" prompt="请选择" name="user.u_role" selectedValue="<s:property value='user.u_role==0?"":user.u_role'/>" data='<s:property value="map['liseb']" escape="false"/>'></select><span class="star">*</span>
					</td>
					<td>所属部门：</td>
					<td>
						<select class="validate[required]" prompt="请选择" name="user.u_ltd" selectedValue="<s:property value='user.u_ltd==0?"":user.u_ltd'/>" data='<s:property value="map['listd']" escape="false"/>'></select><span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td>家庭住址：</td>
					<td colspan="3">
						<textarea name="user.u_address" ><s:property value="user.u_address" /></textarea>
					</td>
				</tr>
				<tr>
					<td colspan="4">
					<input type="button" onclick="checkSubmit()" value="提交" />&nbsp;</td>
				</tr>
			</table>
		</form>
	</div>
</body>
<script type="text/javascript">
var status = "<s:property value='user.u_id' />";
var pwd = $('#pwd').val();
$(function(){
	$('#pwd,#pwdr').val(pwd);
});
function checkSubmit(){
	var actionUrl;
	var valid = $("#form2").validationEngine({returnIsValid: true});
	if(!valid){
		return false;
	}
	if(status=="0"){
		actionUrl = webctx+"/user/user_insertUserById.action";
	}else{
		actionUrl = webctx+"/user/user_updateUserById.action";
	}
	var actionData = $("#form2").serialize();
	$.ajax({
		url:actionUrl,
		data:actionData,
		type : "post",
		cache : false,
		dataType : 'text',
		success : function(data) {
			alert(data);
			if(data.indexOf('失败')!=-1||data.indexOf('存在')!=-1){
				return false;
			}
			top.frmright.window.document.form1.submit();
			top.Dialog.close();
		}
	});
}
</script>
</html>